/**
 *  *2010-3-21 上午12:25:55  add 
 */
package com.base.myproject.server.busi;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Hashtable;

import com.base.myproject.server.database.PoolMan;

/**
 * 从数据库取得权限
 * BusiPermissionDB.getInstance().getPermissDB("1100","999")
 *	(1=2  or bcode like '9%' )
 * @author Administrator
 *2010-3-21
 * javazgw@gmail.com
 */
public class BusiPermissionDB {

	static BusiPermissionDB budb;
	Hashtable<String,String[]> ht = new Hashtable<String,String[]>();
	private BusiPermissionDB()
	{
		
	}
	public static BusiPermissionDB getInstance()
	{
		if(budb==null)
		{
			budb = new BusiPermissionDB();
			
		}
		return budb;
	}
	public String  getPermissDB(String busicode,String bcode) throws Throwable
	{
		String sql = "select permissionsbcode from dbo.busipermissions where bcode like '"+bcode+"%' and busicode ='"+busicode+"'";
		PoolMan pm = new PoolMan();
		ResultSet rs = pm.executeQuery(sql);
		ArrayList<String> al = new ArrayList<String>();
		while(rs.next())
		{
			//用；分割
			String strarray = rs.getString("permissionsbcode");
			for(String str:strarray.split(";"))
			{
				al.add(str);
			}
//			al.add(rs.getString("permissionsbcode"));
			
		}
		return BusiPermission.getInstance().getBusiPer_SQL(al);
		
	}
	public void initCache()
	{
		
	}
	public static void main(String[] argv) throws Throwable
	{
		System.out.println(BusiPermissionDB.getInstance().getPermissDB("1100","999"));
		String sql ="select ## from {PERMISSION}";
		sql = sql.replace("{PERMISSION}",BusiPermissionDB.getInstance().getPermissDB("1100","999"));
		System.out.println(sql);
	}
}
